<template>
  <div class='common-tabs bc-green'>
    <van-tabs color="red" v-model="active" @click="changeTabs">
      <van-tab v-for="(item,index) in menuData" :key="index" :title="item.title"></van-tab>
    </van-tabs>
  </div>
</template>
<script>
import tabsData from "./tabs.js"
export default {
  components: {},
  name: "",
  data() {
    return {
      menuData:[],
      active:"",
    };
  },
  computed:{
    
  },
  methods: {
    init(){
      const path =_router.history.current.path
      tabsData.forEach((ele)=>{
        if(path.indexOf(ele.key)>-1){
          this.$set(this,"menuData",ele.data)
          ele.data.forEach((ele1,index1)=>{
            if(ele1.url===path){
              this.$set(this,"active",index1)
            }
          })
          return
        }
      })
    },

    changeTabs(index,title){
      this.$router.replace(this.menuData[index].url)
    }
  },
  created() {
    this.init()
  }
};
</script>
<style lang="scss" scoped>
.common-tabs {
}
</style>